<?php

/*
 * CopyRight  : (C)2012-2099 HaoTeam Inc.
 * Document   : ConfigValidate.php
 * Created on : 2021-1-31 19:04:38
 * Author     : Tiger <1192851302@qq.com>
 * Description: This is NOT a freeware, use is subject to license terms.
 *              这即使是一个免费软件,使用时也请遵守许可证条款,得到当时人书面许可.
 *              未经书面许可,不得翻版,翻版必究;版权归属 HaoTeam Inc;
 */

namespace haoteam\http\validates;

use think\Validate;

/**
 * 
 * Class ConfigValidate
 * Tiger <1192851302@qq.com> 2021-1-31 19:04:38
 */
class AdminConfigValidate extends Validate {

    protected $rule = [
        'id' => 'require|number',
        'name' => 'require|alphaDash|max:32|unique:admin_config',
        'title' => 'require|chsAlpha|max:10',
        'type' => 'require|alpha',
        'tab_id' => 'require|number'
    ];
    protected $message = [
        'id.require' => 'ID不能为空',
        'id.number' => 'ID格式不正确',
        'name.require' => '字段名称不能为空',
        'name.alphaDash' => '字段名称只能是字母、数字和下划线_及破折号-',
        'name.max' => '字段名称最大32个字符',
        'name.unique' => '字段名称已存在',
        'title.require' => '名称不能为空',
        'title.chs' => '名称只能是汉字与字母',
        'title.max' => '名称最大10个字符',
        'type.require' => '参数类型不能为空',
        'type.alpha' => '参数类型格式不正确',
        'tab_id.require' => '参数分组不能为空',
        'tab_id.number' => '参数分组格式不正确',
    ];
    protected $scene = [
        'create' => ['name', 'title', 'type', 'tab_id'],
        'update' => ['id', 'name', 'title', 'type', 'tab_id'],
        'delete' => ['id']
    ];

}
